/**
 * @author Bondar Ferenc <bondar.ferenc@info.uvt.ro>
 * @version 1.0
 * @since 2012-02-28
 * 
 * Un arbore are ca si trasatura predominanta radadina sa. 
 * Radacina memoreaza la randul ei doua referinte catre fiecare dintre clasele sale fiu. 
 * La fel fiaecare fiu memoreaza referinte catre fii sai si tot asa mai departe. 
 */
/** This class is the implementation of the functional tree (arbore functional) concept.
 */
package arbori;

import arbori.Nod;
public class ArboreFunctional {
	/**
	 * This class is the implementation of the functional tree (arbore functional) concept. <br />
	 * See <A href="https://sites.google.com/site/sabloanedeproiectare/refactoring" > Design Patterns Lab </A>
	 */
	public Nod radacina;
	/**
	 * 
	 * @param r is the root node
	 */
	public ArboreFunctional(Nod r){
		this.radacina = r;
	}
	
	/**
	 * 
	 * @param x sets the root node to x
	 * @return returns the value if the calculation
	 */
	double calculezValoare(double x){
		radacina.setX(x);
		return radacina.calcul();
	}
	/**
	 * @return returns the root node's value in a string
	 */
	public String toString(){
		return radacina.toString();
	}
	/**
	 * 
	 * @return Returns the derived value.
	 */
	public String derivata(){
		return radacina.derivare();
	}
	/**
	 * 
	 * @return Get the root node.
	 */
	 public Nod getRadacina() {
		return radacina;
	}
	/**
	 * 
	 * @param radacina Set the root node.
	 */
	public void setRadacina(Nod radacina) {
		this.radacina = radacina;
	}

	/** 
	 *
	 * @param x calculates the value of x
	 */
	double calculezDerivata(double x){
		radacina.setX(x);
		return radacina.calculDerivata();
	}
}
